home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / share / gufw / instance.pyc (.txt) < prev   
Python Compiled Bytecode  |  2009-11-02  |  2KB  |  71 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import gtk
  5. import os
  6. import os.path as os
  7. from model.Variable import Variable
  8. variable = Variable()
  9.  
  10. class Check:
  11.     
  12.     def is_root(self):
  13.         if os.geteuid() == 0:
  14.             return True
  15.         dlg = gtk.MessageDialog(None, buttons = gtk.BUTTONS_CLOSE, message_format = variable.get_text('018'))
  16.         dlg.run()
  17.         dlg.destroy()
  18.         return False
  19.  
  20.  
  21.  
  22. class Instance:
  23.     
  24.     def __init__(self):
  25.         self.pid_file = variable.get_path('pid_file')
  26.         self.check()
  27.         self.startApplication()
  28.  
  29.     
  30.     def check(self):
  31.         if not os.path.isfile(self.pid_file):
  32.             return None
  33.         pid = 0
  34.         
  35.         try:
  36.             file = open(self.pid_file, 'rt')
  37.             data = file.read()
  38.             file.close()
  39.             pid = int(data)
  40.         except:
  41.             os.path.isfile(self.pid_file)
  42.  
  43.         if 0 == pid:
  44.             return None
  45.         
  46.         try:
  47.             os.kill(pid, 0)
  48.         except:
  49.             0 == pid
  50.             os.path.isfile(self.pid_file)
  51.             return None
  52.  
  53.         exit(0)
  54.  
  55.     
  56.     def startApplication(self):
  57.         file = open(self.pid_file, 'wt')
  58.         file.write(str(os.getpid()))
  59.         file.close()
  60.  
  61.     
  62.     def exitApplication(self):
  63.         
  64.         try:
  65.             os.remove(self.pid_file)
  66.         except:
  67.             pass
  68.  
  69.  
  70.  
  71.